package com.industrial.auth.service;

import cn.hutool.core.util.IdUtil;
import com.industrial.common.core.domain.R;
import com.industrial.system.api.RemoteUserService;
import com.industrial.system.api.domain.BizAccountMapping;
import com.industrial.system.api.domain.SysUser;
import com.industrial.system.api.domain.BizAccountMapping;
import com.industrial.system.api.model.LoginUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;


import java.util.Date;
import java.util.Map;

/**
 * 山东省身份认证平台Service类
 */
@Service
public class IdentityAuthenticationService {

    private static final Logger log = LoggerFactory.getLogger(IdentityAuthenticationService.class);
    private RemoteUserService remoteUserService;

    public IdentityAuthenticationService(RemoteUserService remoteUserService) {
        this.remoteUserService = remoteUserService;
    }

    /**
     * 通过省用户ID查询用户信息
     * <p>
     *     如果没有查询到用户数据<br>
     *     就是用户与省用户关系表中新增一条数据<br>
     *     如果查询到数据则反回该用户信息
     * </p>
     * @param userInfoMap 省用户信息
     */
    public LoginUser selectUserInfoByZwfuUuid(Map<String, Object> userInfoMap) {
        R<LoginUser> bizAccountMappingR = remoteUserService.selectUserMappingInfoByZwfwuuid(userInfoMap);
        if(bizAccountMappingR.getCode() == R.SUCCESS){
            return bizAccountMappingR.getData();
        }else{
            log.error("远程调失败:{}",bizAccountMappingR.getMsg());
            return null;
        }
    }
}
